Skip to content

feat(serde): support serde on SessionOptions and SpeechOptions#4

Merged
uqio merged 4 commits intomainfrom
0.2.0
Apr 21, 2026
Merged

feat(serde): support serde on SessionOptions and SpeechOptions#4
uqio merged 4 commits intomainfrom
0.2.0

Conversation

@uqio
Copy link
Copy Markdown
Collaborator

@uqio uqio commented Apr 21, 2026

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds optional serde support for option types and updates SpeechOptions to use Duration instead of millisecond u32 fields, aligning the crate’s configuration surface with more idiomatic Rust time handling.

Changes:

  • Add serde feature (with humantime-serde) and derive Serialize/Deserialize for SessionOptions, SpeechOptions, and SampleRate.
  • Replace SpeechOptions duration fields/accessors/builders from *_ms: u32 to Duration-based APIs.
  • Apply cfg_attr(not(tarpaulin), inline(always)) in a few hot/leaf methods and bump crate version + changelog.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/options.rs Introduces serde support and refactors SpeechOptions to Duration + adds serde-focused tests.
src/session.rs Applies cfg_attr(not(tarpaulin), inline(always)) to several constructors/helpers.
src/detector.rs Adapts to SpeechOptions no longer being Copy (uses .clone()) and minor inline attribute changes.
examples/streaming.rs Adjusts example to clone SpeechOptions for reuse.
Cargo.toml Bumps version to 0.2.0 and adds optional serde dependencies + feature.
CHANGELOG.md Documents 0.2.0 changes (serde support + Duration migration).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/options.rs Outdated
Comment thread src/options.rs
Comment on lines 154 to 161
impl SessionOptions {
/// Create a new `SessionOptions` with default values.
#[cfg_attr(not(tarpaulin), inline(always))]
pub const fn new() -> Self {
Self {
optimization_level: GraphOptimizationLevel::Disable,
optimization_level: GraphOptimizationLevel::Level3,
}
}
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SessionOptions::new() sets optimization_level to Level3, but the serde default for a missing field is Disable and the unit test below expects SessionOptions::default() to be Disable. This inconsistency will fail tests and makes deserialization of {} not match SessionOptions::default(). Align these defaults (either revert new() to Disable or update the serde default + tests/docs to match the intended new default).

Copilot uses AI. Check for mistakes.
Comment thread src/options.rs
Comment on lines 297 to +306
/// Returns the minimum duration of detected speech segments, in milliseconds.
#[cfg_attr(not(tarpaulin), inline(always))]
pub const fn min_speech_duration_ms(&self) -> u32 {
self.min_speech_duration_ms
pub const fn min_speech_duration(&self) -> Duration {
self.min_speech_duration
}

/// Returns the minimum duration of silence required to close a detected speech segment, in milliseconds.
#[cfg_attr(not(tarpaulin), inline(always))]
pub const fn min_silence_duration_ms(&self) -> u32 {
self.min_silence_duration_ms
pub const fn min_silence_duration(&self) -> Duration {
self.min_silence_duration
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These docs still say "in milliseconds" but the APIs now return Duration (and allow non-ms values when constructed programmatically / via serde). Update the wording to describe Duration (and, if you intentionally treat values as ms-precision, document the rounding/truncation behavior).

Copilot uses AI. Check for mistakes.
Comment thread src/options.rs Outdated
Comment thread src/options.rs Outdated
uqio and others added 3 commits April 21, 2026 18:23
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

@uqio uqio merged commit b273cb3 into main Apr 21, 2026
13 checks passed
@uqio uqio deleted the 0.2.0 branch April 21, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants